<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>my first export PDF</title>
    <style type="text/css" media="print">
        @page rotated{size:landscape;}
    </style>
</head>

<body>
    <script src="pdfmake.min.js"></script>
    <script src="vfs_fonts.js"></script>
    <script>
        var temp_name = window.location.search;
        var name = temp_name.split("=")[1];
        var name_decode = decodeURI(name);
         function down(name) {
            var dd = {
                content: [
                    { text: '管网系统', style: "header" },
                    {
                        columns: [
                            {
                                width: '20%',
                                text: "作者:王忠燕"
                            }, {
                                width: "*",
                                text: ""
                            }, {
                                width: "25%",
                                text: "时间：2018-06-22"
                            }
                        ],
                        marginTop: 20,
                        marginBottom: 20
                    },
                    {
                        width: '550',
                        alignment: "center",
                        image: ''
                    },
                    {
                        text: "管网", style: "pipe"
                    },
                    {
                        style:"tableStyle",
                        table: {
                            widths: ['*',60,60,80,60,60,60,'*'],
                            body: [
                                ['序号', '区域', '管道编号', '管道安装时间', '管材', '瞬时流量', '瞬时压力', '备注'],
                                ['1', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['2', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['3', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['4', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['5', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['6', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['7', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['8', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                            ]
                        }
                    },
                    {
                        text: "消防栓", style: "pipe"
                    },
                    {
                        style:"tableStyle",
                        table: {
                            widths: ['*',60,60,80,60,60,60,'*'],
                            body: [
                                ['序号', '区域', '管道编号', '管道安装时间', '管材', '瞬时流量', '瞬时压力', '备注'],
                                ['1', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['2', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['3', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['4', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['5', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['6', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['7', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                                ['8', '临河大道', 'NXST-0001', '2011-03-11', '球墨铸铁管', '26L/s', '0.45Mpa', ''],
                            ]
                        },
                        margin:[0,0]
                    }
                ],
                defaultStyle: {
                    font: '方正姚体'
                },
                styles: {
                    header: {
                        fontSize: 22,
                        bold: true,
                        alignment: "center"
                    },
                    pipe: {
                        fontSize: 22,
                        bold: true,
                        alignment: "center",
                        marginTop: 20,
                        marginBottom: 20
                    },
                    tableStyle:{
                        margin:[0,0,0,0],
                        alignment:'center'
                    }
                }
            };
            pdfMake.fonts = {
                Roboto: {
                    normal: 'Roboto-Regular.ttf',
                    bold: 'Roboto-Medium.ttf',
                    italics: 'Roboto-Italic.ttf',
                    bolditalics: 'Roboto-Italic.ttf'
                },
                方正姚体: {
                    normal: 'FZYTK.TTF',
                    bold: 'FZYTK.TTF',
                    italics: 'FZYTK.TTF',
                    bolditalics: 'FZYTK.TTF',
                }
            };

            pdfMake.createPdf(dd).download(name_decode+'.pdf');
        }
        window.onload=function(){
            down(name);
        }
    </script>
</body>

</html>